Skip to content

fix(harness): count tool call arguments once in context estimates - #4499

Merged
jujn merged 2 commits into
agentscope-ai:mainfrom
iluv7:fix/4495-tool-arguments-token-estimate
Dec 3, 2026
Merged

jujn merged 2 commits into
agentscope-ai:mainfrom
iluv7:fix/4495-tool-arguments-token-estimate

Conversation

@iluv7

@iluv7 iluv7 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #4495

Count tool-call arguments once in ContextTokenEstimator.approximate() using JsonUtils.resolveToolCallArgsJson(). This uses the same argument selection and sanitization as the formatter instead of adding both parsed input and raw content.

Adds regression tests for duplicate streamed arguments, raw argument precedence, empty/invalid argument fallback, malformed argument sanitization, and retaining thinking content in the estimate.

Validation (Java 17):

  • New regression tests: 7 of 10 failed before the fix; all 10 pass after it.
  • mvn -B -T1C -pl agentscope-harness -am test spotless:check passes. Test summaries report 607 and 2,301 tests, with 37 skipped and no failures or errors.
  • git diff --check passes.

@iluv7

iluv7 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Windows CI hit a timeout in an existing test. Plz rerun the failed job. Thanks!
cc @jujn

@iluv7

iluv7 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, @xzxiaoshan, the ci looks good.

@iluv7

iluv7 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi, @jujn could you ptal at this PR when you get a chance?

@jujn
jujn merged commit 4abccdb into agentscope-ai:main Dec 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ContextTokenEstimator counts parsed and streamed tool arguments twice

3 participants